<template>
  <div id="sortDialog">
    <el-dialog
      class="editDialog"
      title="编辑排序"
      :visible.sync="editDialogData.isShow"
      width="25%"
      top="35vh"
    >
      <el-form
        ref="sortForm"
        :model="sortForm"
        label-width="80px"
        @submit.native.prevent
      >
        <el-form-item label="排序号">
          <el-input-number
            v-model="sortForm.order"
            controls-position="right"
            :min="1"
            class="sort-input-num"
          ></el-input-number>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" plain @click="editDialogData.isShow = false"
          >关 闭</el-button
        >
        <el-button type="success" class="submitPass" @click="submitPass"
          >提 交</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { editSortAPI } from '@/api/operate/active'

export default {
  props: ['editDialogData'],
  data() {
    return {
      sortForm: {
        order: ''
      }
    }
  },
  mounted() {
    this.sortForm.order = this.editDialogData.order
  },
  methods: {
    // 点击确定
    submitPass() {
      let id = this.editDialogData.id
      let params = {
        order: this.sortForm.order
      }
      editSortAPI(
        id,
        params,
        (response) => {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$emit('refresh')
          this.editDialogData.isShow = false
        },
        (response) => {
          this.$message({
            message: response.message,
            type: 'warning'
          })
        }
      )
    }
  }
}
</script>
<style lang="less" scoped>
#sortDialog {
  .sort-input-num {
    width: 200px;
  }
}
</style>
